package com.nCoV.EpidemicSurveillance.config; 
/** 
* @author 作者 罗穆健: 
* @version 创建时间：2020年1月5日 下午11:00:57 
* 类说明 
*/

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.nCoV.EpidemicSurveillance.common.utils.GsonUtil;
import com.nCoV.EpidemicSurveillance.domain.UrlResponse;

@Service
public class UrlAccessDeniedHandler implements AccessDeniedHandler {
	@Override
    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException {
		
        Map<String,Object> map = new HashMap<String,Object>();
		map.put("code",403);
		map.put("message","账号权限不足");
		httpServletResponse.setContentType("application/json;charset=utf-8");
		PrintWriter out = httpServletResponse.getWriter();
		out.write(new ObjectMapper().writeValueAsString(map));
		out.flush();
		out.close();
    }
}
 